package com.xtyhz.controller;


import com.xtyhz.model.R;
import com.xtyhz.model.req.WxLoginRequest;
import com.xtyhz.model.vo.UserLoginVO;
import com.xtyhz.service.UserService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 用户控制器
 */
@Tag(name = "用户管理", description = "用户管理相关接口")
@RestController
@RequestMapping("/user")
public class UserController {
    
    @Autowired
    private UserService userService;
    
    /**
     * 微信登录
     * @param loginRequest 登录请求
     * @return 登录结果
     */
    @Operation(summary = "微信登录", description = "通过微信授权登录系统，获取用户令牌")
    @PostMapping("/login")
    public R<UserLoginVO> login(@RequestBody WxLoginRequest loginRequest) {
        UserLoginVO loginVO = userService.wxLogin(loginRequest);
        return R.ok(loginVO, "登录成功");
    }
}
